package com.vincent.suchao.lcld;

import com.vincent.suchao.adapter.ContactsAdapter;
import com.vincent.suchao.adapter.MembersAdapter;
import com.vincent.suchao.adapter.NineMenuAdapter;
import com.vincent.suchao.entity.MyContacts;
import com.vincent.suchao.entity.MyContacts.ContactItem;
import com.vincent.suchao.entity.NineMenuItem;
import com.vincent.suchao.entity.TeamMembers.Member;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class TDJS_Activity extends Activity implements OnClickListener, OnItemClickListener {
	private TextView tv_tittle;
	private Button b_back;
	private ListView lv_tdjs;
	private MembersAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_tdjs);
		init();
	}

	private void init() {
		tv_tittle = (TextView) findViewById(R.id.tv_tittle);
		tv_tittle.setText(getString(R.string.menu_com_tdjs));
		b_back = (Button) findViewById(R.id.b_back);
		b_back.setOnClickListener(this);
		lv_tdjs = (ListView) findViewById(R.id.lv_tdjs);
		mAdapter = new MembersAdapter(this);
		lv_tdjs.setAdapter(mAdapter);
		lv_tdjs.setOnItemClickListener(this);
		int isFromTabhost = getIntent().getIntExtra(TabHostActivity.TABACTIVITY_TAG, 0);
		if (isFromTabhost == 1)
			b_back.setVisibility(View.GONE);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.gsjj, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {

		case R.id.b_back:
			finish();
			break;
		default:
			break;
		}

	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

		RelativeLayout rl_inflater_contact = (RelativeLayout) arg1.findViewById(R.id.rl_inflater_member);
		Member member = (Member) rl_inflater_contact.getTag(R.id.rl_inflater_member);
		Intent intent = new Intent();
		intent.setClass(this, TDJS_DetailActivity.class);

		switch (member.getResID()) {
		case R.drawable.tdjs1:
			intent.putExtra(Member.KEY_MEMBER, R.drawable.tdjs1);
			break;
		case R.drawable.tdjs2:
			intent.putExtra(Member.KEY_MEMBER, R.drawable.tdjs2);
			break;
		case R.drawable.tdjs3:
			intent.putExtra(Member.KEY_MEMBER, R.drawable.tdjs3);
			break;
		case R.drawable.tdjs4:
			intent.putExtra(Member.KEY_MEMBER, R.drawable.tdjs4);
			break;
		case R.drawable.tdjs5:
			intent.putExtra(Member.KEY_MEMBER, R.drawable.tdjs5);
			break;
		case R.drawable.tdjs6:
			intent.putExtra(Member.KEY_MEMBER, R.drawable.tdjs6);
			break;
		default:
			break;
		}
		startActivity(intent);
	}

}
